<template>
	<div class="hy-container">
		<HyPageHeader title="资料修改详情" :buttonData="buttonData">
			<Schedule v-loading="loading" :processInstanceId="routerParams.processInstanceId" />
			<div class="mt-5"></div>
			<div v-loading="loading" v-if="routerParams.businessType === '1'">
				<EditInfo :editData="editData" />
				<div class="mt-5"></div>
				<ThreeListData :detailData="detailData?.threeList" :editData="editData" />
			</div>
			<div v-loading="loading" v-if="routerParams.businessType === '2'">
				<detailCom :detailInfo="detailDatas" />
			</div>
			<div class="mt-5"></div>
			<History v-loading="loading" :processInstanceId="routerParams.processInstanceId" />
		</HyPageHeader>
		<ExamineBox ref="examineBoxRef" @submitPass="submitPass"></ExamineBox>
	</div>
</template>
<script setup lang="ts">
import HyPageHeader from '/@/components/HyPageHeader/index.vue';
import { fileEditDetailApi } from '/@/api/fileEdit';
import ThreeListData from './components/ThreeListData/index.vue';
import EditInfo from './components/EditInfo/index.vue';
import detailCom from '/@/views/digitalList/detail/detailCom.vue';
import mittBus from '/@/utils/mitt';
import { getRouterParams } from '/@/utils/hyFunc';
import ExamineBox from '@cqdcg/admin/views/flow/task/examineBox';
import Schedule from '@cqdcg/admin/views/flow/task/Schedule/index';
import History from '@cqdcg/admin/views/flow/task/History/index';
//获取资料修改详情
const loading = ref(false);
const detailData = ref();
const editData = ref();
const detailDatas = ref({
	info: {
		base: {
			appCode: '',
		},
		net: {},
		irs: {},
		dev: {},
		budget: {},
		calculate: {},
	},
});
//审核
const examineBoxRef = ref();
const handleApprove = () => {
	examineBoxRef.value.handle({
		processInstanceId: routerParams.value.processInstanceId,
	});
};
const route = useRoute();
const submitPass = () => {
	mittBus.emit('onCurrentContextmenuClick', Object.assign({}, { contextMenuClickId: 1, ...route }));
};
//获取详情
const routerParams = ref(getRouterParams());
const getFileEditDetailData = () => {
	loading.value = true;
	fileEditDetailApi({ dataModifyId: routerParams.value.dataModifyId })
		.then((res) => {
			if (routerParams.value.businessType === '1') {
				detailData.value = res;
				editData.value = {
					applyPersonName: res.applyPersonName || '',
					applyTime: res.applyTime || '',
					applyReason: res.applyReason || '',
				};
			}
			if (routerParams.value.businessType === '2') {
				detailData.value = res;
				detailDatas.value.info = res.appDeclare;
			}
		})
		.finally(() => (loading.value = false));
};

onMounted(() => {
	getFileEditDetailData();
});
// 设置操作按钮
const buttonData: any = computed(() => {
	//资料审核列表进入
	if (routerParams.value.processStatus === '1') {
		return [{ name: '审核', click: () => handleApprove(), class: 'blue-button' }];
	}
	return [];
});
</script>
<style scoped lang="scss"></style>
